namespace ghost
{
    export class CallItem extends GYSprite
    {
        public back:GYSprite;
        public title:Laya.Text;
        public nameLab:Laya.Text;
        public icon:GYSprite;
        public index:number;
        constructor(index:number, tex:Laya.Texture)
        {
            super();
            let s = this;            
            s.index = index;
            s.back = new GYSprite;
            s.back.texture = Main.instance.getRes(Conf.scene + "card.png");
            s.addChild(s.back);
            s.width = s.back.width;
            s.height = s.back.height;
            
            s.title = new Laya.Text;
            s.title.color = "#ffffff";
            s.title.fontSize = 30;
            s.title.strokeColor = "#000000";
            s.title.stroke = 6;
            s.title.text = Main.gameConfig.skills[index].name;
            s.title.width = s.back.width;
            s.title.y = 15;
            s.title.align = "center";
            s.addChild(s.title);

            s.nameLab = new Laya.Text;
            s.nameLab.color = "#ffffff";
            s.nameLab.fontSize = 20;
            s.nameLab.strokeColor = "#000000";
            s.nameLab.stroke = 4;
            s.nameLab.text = Main.gameConfig.skills[index].desc;
            s.nameLab.width = s.back.width;
            s.nameLab.align = "center";
            s.nameLab.y = 280;
            s.addChild(s.nameLab);

            s.icon = new GYSprite;
            s.icon.texture = tex;
            s.icon.y = 70;
            s.icon.x = s.back.width - s.icon.width >> 1;
            s.addChild(s.icon);

        }
        public setSelect(val:boolean):void
        {
            let s = this;
            s.back.texture = Main.instance.getRes(Conf.scene + (val?"effectCard.png":"card.png"));
        }
        public reset():void
        {
            let s = this;
            let gold:number = MyPlayerData.getInstance().gold;
            let obj:any = Main.gameConfig.skills[s.index];
            let cost:number = Main.getTowerLvUpCost(obj.roleID);
            s.disabled = gold < cost;
        }
    }
}